<template>
  <a-layout class="home">
    <a-layout-header class="header"><HeaderVue /></a-layout-header>
    <a-layout-content class="content flex">
      <div class="sider">
        <div class="all-menu">
          <div class="all-menu-content">
            <div class="title-Heaer flex" @click="changeRouter('/')">
              <div class="icon"><MenuOutlined /></div>
              <div class="title">应用与分类</div>
            </div>
            <div class="menu-list">
              <div
                class="menu-item flex"
                v-for="(item, index) in menuList"
                :key="index"
                @click="changeRouter(item)"
              >
                <div class="icon"><menuIcon :icon="item?.meta?.icon" /></div>
                <div class="title">{{ item?.meta?.title }}</div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="content flex-1"><router-view /></div>
    </a-layout-content>
  </a-layout>
</template>
<script setup>
import { ref, reactive } from "vue";
import { MenuOutlined } from "@ant-design/icons-vue"; // 图标
import HeaderVue from "./component/Header.vue"; // 页头
import menuIcon from "./component/menuIcon.vue";
import { menuList } from "@/router/index"; // 菜单
import { useRouter, useRoute } from "vue-router";
const router = useRouter();

const changeRouter = (params) => {
  if (params.path.indexOf("/:page*") > 0) {
    let path = params.path.replace("/:page*", "");
    router.push(path);
  } else {
    router.push(params.path);
  }
};
</script>
<style lang="less" scoped>
.home {
  height: 100%;
}
.sider {
  background: none;
  border-right: 1px solid #e7ecf4;
  box-shadow: 1px 2px 4px 0 rgba(0, 0, 0, 0.05);
  width: 50px;
  z-index: 100;
}
.header {
  background: none;
  border-bottom: 1px solid #e7ecf4;
  box-shadow: 1px 2px 4px 0 rgba(0, 0, 0, 0.05);
}
.content {
  background: none;
  box-shadow: inset 0 1px 0 0 #eee, inset 0 -1px 0 0 #eee;
}

.all-menu {
  width: 50px;
  height: 100%;

  .all-menu-content {
    height: 100%;
    width: 50px;
    transition: all 0.3s ease-out;
    background: #fff;
    overflow: hidden;
    &:hover {
      width: 200px;
    }
    .title-Heaer {
      width: 200px;
      height: 50px;
      line-height: 50px;
      border-bottom: 1px solid #e7ecf4;
      cursor: pointer;
      &:hover {
        background: #dee9ff;
      }
      .icon {
        height: 50px;
        line-height: 50px;
        width: 50px;
        text-align: center;
        border-right: 1px solid #e7ecf4;
      }
      .title {
        padding-left: 10px;
      }
    }
  }
  .menu-list {
    width: 200px;
    line-height: 40px;
    cursor: pointer;
    .menu-item {
      &:hover {
        background: #dee9ff;
      }
      .icon {
        height: 40px;
        line-height: 40px;
        width: 50px;
        text-align: center;
        border-right: 1px solid #e7ecf4;
      }
      .title {
        padding-left: 10px;
      }
    }
  }

  .transition {
    transition: all 300ms;
  }
}
</style>